//
//  QSSV_HUDTool.m
//  myTest
//
//  Created by Song on 2017/9/14.
//  Copyright © 2017年 Song. All rights reserved.
//

#import "QSSV_HUDTool.h"
#import <SVProgressHUD.h>

@implementation QSSV_HUDTool
/**
 *  设置提示框的样式
 */
+ (void)sv_setupHUDStyle
{
    // 转圈或者是菊花
    [SVProgressHUD setDefaultAnimationType:SVProgressHUDAnimationTypeFlat];
    // 菊花颜色
    [SVProgressHUD setDefaultStyle:SVProgressHUDStyleLight];
    // 加一个黑的半透明的遮罩view
    [SVProgressHUD setDefaultMaskType:SVProgressHUDMaskTypeBlack];
}

/**
 *  设置显示时间
 */
+ (void)setDismissTimeInterval
{
    [SVProgressHUD setMinimumDismissTimeInterval:1.0];
    [SVProgressHUD setMaximumDismissTimeInterval:2.0];
}

#pragma mark - 封装提示框的显示方法
/**
 *  加载进度提示框
 *
 *  @param message 提示信息
 */
+ (void)sv_showLoadingHUDWithMessage:(NSString *)message
{
    [self sv_setupHUDStyle];
    [SVProgressHUD showWithStatus:message];
}

/**
 *  只有加载进度的提示框
 */
+ (void)sv_showLoadingHUDWithoutMessage
{
    [self sv_setupHUDStyle];
    [SVProgressHUD show];
}

/**
 *  加载成功提示框
 *
 *  @param message 提示信息
 */
+ (void)sv_showSuccessHUDWithMessage:(NSString *)message
{
    [self setDismissTimeInterval];
    
    [SVProgressHUD showSuccessWithStatus:message];
}

/**
 *  加载失败提示框
 *
 *  @param message 提示信息
 */
+ (void)sv_showFailHUDWithMessage:(NSString *)message
{
    [self setDismissTimeInterval];
    
    [SVProgressHUD showErrorWithStatus:message];
}

/**
 *  只有文字的提示框
 *
 *  @param message 提示信息
 */
+ (void)sv_showHUDOnlyWithMessage:(NSString *)message
{
    [self setDismissTimeInterval];
    [SVProgressHUD showImage:[UIImage imageNamed:@""] status:message];
}

/**
 *  带警告图标的提示框
 *
 *  @param message 提示信息
 */
+ (void)sv_showInfoHUDWithMessage:(NSString *)message
{
    [self setDismissTimeInterval];
    [SVProgressHUD showInfoWithStatus:message];
}

/**
 *  隐藏提示框，带Block
 */
+ (void)sv_dismissHUDWithDelay:(NSTimeInterval)delay Completion:(void (^)(void))dismissCompletion
{
    [SVProgressHUD dismissWithDelay:delay completion:^{
        dismissCompletion();
    }];
}

/**
 *  隐藏提示框
 */
+ (void)sv_dismissHUD
{
    [SVProgressHUD dismiss];
}

@end
